package UIFree.controls {
	import UIFree.uif_component;
	
	import flash.events.MouseEvent;

	public class uif_hscrollButon extends uif_arrowbutton	{
		public static var UNFOCUS_ALPHA: Number = 0.5;
		
		public function uif_hscrollButon(parent: uif_hscrollArea, ax:int=0, ay:int=0, awidth:int=0, aheight:int=0, orientation: int=1, styleClass:String='') {
			super(parent, ax, ay, awidth, aheight, orientation, styleClass);

			setFocus(hitMouse);
			this.addEventListener(MouseEvent.MOUSE_OVER, function(e: MouseEvent): void {
				if (!disable) setFocus(true);
			});
			this.addEventListener(MouseEvent.MOUSE_OUT, function(e: MouseEvent): void {
				if (!disable) setFocus(false);
			});
		}
		
		private function get isFieldFocusStyle(): Boolean {
			return style.hasOwnProperty(uif_component.FIELD_FOCUSSTYLE);
		}
		
		protected function setFocus(a_focus: Boolean): void {
			if (a_focus) {
				if (isFieldFocusStyle) styleFX(style, app.styleByObj(style[uif_component.FIELD_FOCUSSTYLE])).start();
				else alphaFX(1); 
			} else {
				if (isFieldFocusStyle) styleFX(style, app.styleByName(styleClass)).start();
				else alphaFX(UNFOCUS_ALPHA);
			}
		}
		
		override protected function disableVisualization(): void {
			if (disable) alphaFX(0);
			else {
				if (isFieldFocusStyle) alpha = 1;
				setFocus(hitMouse);
			}
		}
	}
}